package defpackage; import cn.wps.moffice.OfficeApp; import cn.wps.moffice_eng.R; import cn.wps.util.JSONUtil; import com.google.gson.reflect.TypeToken; import com.iflytek.cloud.SpeechConstant; import com.iflytek.cloud.SpeechUtility; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* renamed from: gwp reason: default package */ public final class gwp { private static gwp hGP; boolean gLs = false; public long hGO; List<gwo> hGQ = new ArrayList(); /* renamed from: gwp$a */ public interface a { void bk(List<gwo> list); } /* access modifiers changed from: package-private */ /* renamed from: gwp$b */ public class b extends fcv<String, Void, List<gwo>> { a hGR; public b(a aVar) { this.hGR = aVar; } private List<gwo> bVV() throws IOException, JSONException { OfficeApp arx = OfficeApp.arx(); String f = lwd.f("https://moapi.wps.cn/msg/api/p/message/broadcast/page" + lwv.a("?version=%s&channel=%s&pchannel=%s&position=%s&page=1&size=50", arx.getString(R.string.app_version), arx.arA(), arx.arB(), "notice"), null); ArrayList arrayList = new ArrayList(); if (f != null) { try { JSONObject jSONObject = new JSONObject(f); if (jSONObject.optInt(SpeechUtility.TAG_RESOURCE_RESULT) == 0) { gwp.this.hGO = System.currentTimeMillis(); JSONArray jSONArray = jSONObject.getJSONArray("messages"); if (jSONArray != null && jSONArray.length() > 0) { for (int i = 0; i < jSONArray.length(); i++) { arrayList.add((gwo) JSONUtil.getGson().fromJson(jSONArray.getJSONObject(i).toString(), new TypeToken<gwo>() { /* class defpackage.gwp.b.AnonymousClass1 */ }.getType())); } } return arrayList; } } catch (JSONException e) { throw e; } } return arrayList; } private List<gwo> bVW() throws IOException, JSONException { HashMap hashMap = new HashMap(); hashMap.put(SpeechConstant.IST_SESSION_ID, ebo.arU() ? fok.bBq().getWPSSid() : ""); OfficeApp arx = OfficeApp.arx(); String f = lwd.f("https://moapi.wps.cn/msg/api/p/message/unread" + lwv.a("?version=%s&channel=%s&pchannel=%s&position=%s&size=50", arx.getString(R.string.app_version), arx.arA(), arx.arB(), "notice"), hashMap); ArrayList arrayList = new ArrayList(); if (f != null) { try { JSONObject jSONObject = new JSONObject(f); if (jSONObject.optInt(SpeechUtility.TAG_RESOURCE_RESULT) == 0) { gwp.this.hGO = System.currentTimeMillis(); JSONArray jSONArray = jSONObject.getJSONArray("messages"); if (jSONArray != null && jSONArray.length() > 0) { for (int i = 0; i < jSONArray.length(); i++) { arrayList.add((gwo) JSONUtil.getGson().fromJson(jSONArray.getJSONObject(i).toString(), new TypeToken<gwo>() { /* class defpackage.gwp.b.AnonymousClass2 */ }.getType())); } } return arrayList; } } catch (JSONException e) { throw e; } } return arrayList; } private List<gwo> bvK() { gwp.this.hGQ.clear(); try { gwp.this.hGQ.addAll(bVV()); } catch (Exception e) { } try { if (ebo.arU()) { gwp.this.hGQ.addAll(bVW()); } } catch (Exception e2) { } return gwp.this.hGQ; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object[]] */ /* access modifiers changed from: protected */ @Override // defpackage.fcv public final /* synthetic */ List<gwo> doInBackground(String[] strArr) { return bvK(); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ /* access modifiers changed from: protected */ @Override // defpackage.fcv public final /* synthetic */ void onPostExecute(List<gwo> list) { this.hGR.bk(list); gwp.this.gLs = false; } /* access modifiers changed from: protected */ @Override // defpackage.fcv public final void onPreExecute() { } } public static gwp bVU() { if (hGP == null) { hGP = new gwp(); } return hGP; } public final synchronized void a(a aVar) { if (!this.gLs) { if (Math.abs(System.currentTimeMillis() - this.hGO) < gwn.d(15, fvd.bP("member_messagecenter", "messagebar_update")) * 60 * 1000) { aVar.bk(this.hGQ); } else { this.gLs = true; new b(aVar).execute(new String[0]); } } } }